<%@ page  language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>放映厅管理页面</title>
    <%@ include file="../comm.jsp" %>
    <style>
        .layui-form{
            margin-left: 20px;
        }
        #add {
            margin-left: 50px;
        }
        .list{
            margin-top: 40px;
        }
        .layui-table{
            width: 95%;
            margin: 0 auto;
        }
        #demo7{
            margin-top: 10px;
            margin-left: 50px;
        }
    </style>
</head>
<body>
<h2 align="center" style="margin-bottom:20px;">放映厅管理</h2>
<%--操作栏--%>
<section>
    <%--添加操作栏--%>
    <a href="javascript:toAdd();" class="layui-btn layui-btn-primary layui-border-green" id="add">
        <i class="layui-icon">&#xe61f;</i>    新建
    </a>
</section>
<%--影厅列表--%>
<section class="list">
    <table class="layui-table" style="text-align: center">
        <colgroup>
            <col width="150">
            <col width="20">
            <col width="150">
            <col width="20">
            <col width="150">
            <col width="20">
            <col width="150">
            <col width="20">
            <col width="150">
            <col width="20">
            <col width="150">
            <col width="20">
        </colgroup>
        <thead>
        <tr>
            <th colspan="10" style="text-align: center"><strong style="font-size: 20px;">影厅名称</strong></th>
        </tr>
        </thead>
        <tbody>
        <tr>
            <c:forEach var="room" items="${requestScope.roomVO.roomList}" varStatus="vs" begin="0" end="4">
                <td><a href="javascript:toEdit(${room.roomId})">${room.roomName}</a></td>
                <td>
                    <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" onclick="toDelete(${room.roomId})">
                    <i class="layui-icon">&#xe640;</i>
                    </button>
                </td>
            </c:forEach>
        </tr>
        <tr>
            <c:forEach var="room" items="${requestScope.roomVO.roomList}" varStatus="vs" begin="5" end="9">
                <td><a href="javascript:toEdit(${room.roomId})">${room.roomName}</a></td>
                <td>
                    <button type="button" class="layui-btn layui-btn-xs layui-btn-danger" onclick="toDelete(${room.roomId})">
                        <i class="layui-icon">&#xe640;</i>
                    </button>
                </td>
            </c:forEach>
        </tr>
        </tbody>
    </table>
    <div id="demo7"></div>
</section>
<%@include file="roomAdd.jsp"%>
<%@ include file="roomSet.jsp"%>
<script>
    var $ ;
    layui.use(['jquery','laypage','form'], function() {
        $ = layui.$ ;
        var laypage = layui.laypage
            ,form = layui.form;
        laypage.render({
            elem: 'demo7'
            , count: ${requestScope.roomVO.total}
            , limit:10
            , curr:${requestScope.roomVO.pageNo}
            , layout: ['count', 'prev', 'page', 'next', 'skip']
            , jump: function (obj,first) {
                if(first){
                    return;
                }
                toFind(obj.curr);
            }
        });
    });
    function toFind(pageNo){
        window.location.href="personnelroom?pageNo="+pageNo;
    }
    function toEdit(roomId){
        $.get("forEditRoom",{
            roomId:roomId
        },function (data){
            if(data!=null){
                $('#roomId').val(data.roomId);
                $('#setRoomName').val(data.roomName);
            }else {
                layer.msg("错误",{icon:0});
            }
        })
        layer.open({
            type:1,
            title:'新建影厅',
            area:[500,200],
            content:$('#editForm')
        });
    }
    function  toAdd(){
        layer.open({
            type:1,
            title:'新建影厅',
            area:[500,200],
            content:$('#roomForm')
        });
    }
    function toDelete(roomId){
        $.get("deleteRoom",{
            roomId:roomId
        },function (code){
            if(code==1){
                layer.msg("删除成功",{icon:1})
            }else if(code==0){
                layer.msg("已删除",{icon:0})
            }else {
                layer.msg("删除失败",{icon:0})
            }
        })
    }
</script>
</body>
</html>